<!--
 * @Author: ChunLai
 * @Date: 2022-01-04 09:40:49
 * @LastEditTime: 2025-09-04 17:26:19
 * @Description: 公共页
 * @FilePath: \02.bldinsure\src\views\prenotice\simple\Common.vue
-->
<template>
  <div class="healthy-wrap">
    <TipMsg :msg="tipMsg" v-if="tipMsg !== ''"></TipMsg>
    <div class="md-title" v-if="noticeLen > 1">
      <span
        class="title-span font3"
        :class="{
          active: idx === activeIndex,
          'len1-width': pageData.length == 1,
        }"
        v-for="(unit, idx) in pageData"
        :key="idx"
        @click="changeMd(idx)"
      >
        {{
          `${unit.userType == "bbr" ? "被保险人" : "投保人"}${unit.moduleName}`
        }}
      </span>
    </div>
    <div class="modules" v-if="pageData.length > 0">
      <ul class="module-ul">
        <li
          class="module-li"
          v-for="(que, idx) in noticeObj.questionsList"
          :key="`que-${idx}`"
        >
          <div class="li-label">
            <b class="font2">{{ `${idx + 1}` }}</b
            >、{{ que.impartContent }}
          </div>
          <template v-if="que.sedLists && que.sedLists.length > 0">
            <p
              class="sed-li"
              v-for="(sed, i) in que.sedLists"
              :key="`sed-${i}`"
              v-html="sed.cont"
            ></p>
          </template>
        </li>
      </ul>
    </div>
    <FooterBtns
      leftText="有部分问题"
      rightText="确认无以上问题"
      @saveField="leftBtnHandle"
      @saveForm="rightBtnHandle"
    />
  </div>
</template>

<script>
import { simpleMixin } from "./mixin.js";

export default {
  name: "CommonSimple",
  data() {
    return {};
  },
  computed: {},
  mixins: [simpleMixin],
  created() {
    this.initPageDatas();
  },
  mounted() {},
  methods: {
    leftBtnHandle() {
      const uName =
        this.pageData[this.activeIndex].userType === "bbr"
          ? "被保险人"
          : "投保人";
      this.$dialog
        .alert({
          title: `${uName}告知不通过`,
          message: "不能进行投保",
          confirmButtonColor: "#DA251E",
          confirmButtonText: "确认",
        })
        .then(() => {});
    },
    rightBtnHandle() {
      if (this.activeIndex < this.noticeLen - 1) {
        this.activeIndex += 1;
      } else {
        this.$router.push("/files");
        // this.saveNoticeApi(this.noticeObj.ucode);
      }
    },
    saveNoticeApi(type) {
      let params = {
        ...this.apiComParams,
        type: type,
        imparts: JSON.stringify(this.noticeObj.questionsList),
      };
      this.$store
        .dispatch("apis/comAdminApiRequest", {
          apiParams: params,
          apiName: "saveImparts",
          toast: true,
        })
        .then((data) => {
          if (this.activeIndex < this.noticeLen - 1) {
            this.activeIndex += 1;
          } else {
            this.$router.push("/files");
          }
        });
    },
  },
};
</script>

<style lang="less" scoped>
@import "../../healthy/simple/style.less";
</style>
